package com.example.musicplayer;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.LinkedList;

import wcfb.com.view.CircleImageView;

public class MusicAdapter extends BaseAdapter {
    private LinkedList<Music> mData;
    private Context mContext;

    public MusicAdapter(LinkedList<Music> mData, Context mContext){
        this.mData = mData;
        this.mContext =mContext;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.list,parent,false);
        CircleImageView img_icon =  convertView.findViewById(R.id.image);
        TextView txt_song =  convertView.findViewById(R.id.song);
        TextView txt_singer =  convertView.findViewById(R.id.singer);
        img_icon.setBackgroundResource(mData.get(position).getIcon());
        txt_song.setText(mData.get(position).getsong());
        txt_singer.setText(mData.get(position).getsinger());
        return convertView;
    }
}
